Carbon


CloneCollection

Header: Collections.h Carbon status: Supported

Clones a collection object—that is, increment its owner count.

Collection CloneCollection (
    Collection c
);
c

A reference to the collection object you want to clone. The behavior of this function is undefined if you do not provide a reference to a valid collection object.

function result

A reference to the cloned collection. (This result is effectively a copy of the reference you provide in the c parameter.)

DISCUSSION

Typically, you use this function to increment a collection object’s owner count to represent a new reference to the collection object. For example, if you want two variables in your application to reference a single collection object, you can use this code to maintain the correct owner count:

firstReference = NewCollection();

secondReference = CloneCollection(firstReference);

Disposing of either reference (using the DisposeCollection function) simply decrements the collection’s owner count. Disposing of the remaining reference decrements the owner count again and frees the memory associated with the collection.

To decrement the owner count of a collection object, use the DisposeCollection function. To determine the owner count of an existing collection object, use the CountCollectionOwners function.

To copy a collection object, use the CopyCollection function.

AVAILABILITY

Supported in Carbon. Available in Mac OS 8.1 and later when Carbon 1.0.2 or later is present.


© 2000 Apple Computer, Inc. — (Last Updated 5/8/2000)